.class public Lcom/zuiapps/suite/utils/http/CustomHttpClient;
.super Ljava/lang/Object;
.source "CustomHttpClient.java"


# static fields
.field private static final CHARSET_UTF8:Ljava/lang/String; = "UTF-8"

.field private static TAG:Ljava/lang/String;

.field private static customerHttpClient:Lorg/apache/http/client/HttpClient;


# direct methods
.method static constructor <clinit>()V
    .registers 1

    .prologue
    .line 40
    const-string v0, "CustomHttpClient"

    sput-object v0, Lcom/zuiapps/suite/utils/http/CustomHttpClient;->TAG:Ljava/lang/String;

    return-void
.end method

.method private constructor <init>()V
    .registers 1

    .prologue
    .line 45
    invoke-direct {p0}, Ljava/lang/Object;-><init>()V

    .line 47
    return-void
.end method

.method public static varargs PostFromWebByHttpClient(Landroid/content/Context;Ljava/lang/String;[Lorg/apache/http/NameValuePair;)Ljava/lang/String;
    .registers 14
    .param p0, "context"    # Landroid/content/Context;
    .param p1, "url"    # Ljava/lang/String;
    .param p2, "nameValuePairs"    # [Lorg/apache/http/NameValuePair;

    .prologue
    const/4 v8, 0x0

    .line 59
    :try_start_1
    new-instance v4, Ljava/util/ArrayList;

    invoke-direct {v4}, Ljava/util/ArrayList;-><init>()V

    .line 60
    .local v4, "params":Ljava/util/List;, "Ljava/util/List<Lorg/apache/http/NameValuePair;>;"
    if-eqz p2, :cond_14

    .line 61
    const/4 v3, 0x0

    .local v3, "i":I
    :goto_9
    array-length v9, p2

    if-ge v3, v9, :cond_14

    .line 62
    aget-object v9, p2, v3

    invoke-interface {v4, v9}, Ljava/util/List;->add(Ljava/lang/Object;)Z

    .line 61
    add-int/lit8 v3, v3, 0x1

    goto :goto_9

    .line 65
    .end local v3    # "i":I
    :cond_14
    new-instance v7, Lorg/apache/http/client/entity/UrlEncodedFormEntity;

    const-string v9, "UTF-8"

    invoke-direct {v7, v4, v9}, Lorg/apache/http/client/entity/UrlEncodedFormEntity;-><init>(Ljava/util/List;Ljava/lang/String;)V

    .line 67
    .local v7, "urlEncoded":Lorg/apache/http/client/entity/UrlEncodedFormEntity;
    new-instance v2, Lorg/apache/http/client/methods/HttpPost;

    invoke-direct {v2, p1}, Lorg/apache/http/client/methods/HttpPost;-><init>(Ljava/lang/String;)V

    .line 68
    .local v2, "httpPost":Lorg/apache/http/client/methods/HttpPost;
    invoke-virtual {v2, v7}, Lorg/apache/http/client/methods/HttpPost;->setEntity(Lorg/apache/http/HttpEntity;)V

    .line 69
    invoke-static {p0}, Lcom/zuiapps/suite/utils/http/CustomHttpClient;->getHttpClient(Landroid/content/Context;)Lorg/apache/http/client/HttpClient;

    move-result-object v0

    .line 70
    .local v0, "client":Lorg/apache/http/client/HttpClient;
    invoke-interface {v0, v2}, Lorg/apache/http/client/HttpClient;->execute(Lorg/apache/http/client/methods/HttpUriRequest;)Lorg/apache/http/HttpResponse;

    move-result-object v6

    .line 71
    .local v6, "response":Lorg/apache/http/HttpResponse;
    invoke-interface {v6}, Lorg/apache/http/HttpResponse;->getStatusLine()Lorg/apache/http/StatusLine;

    move-result-object v9

    invoke-interface {v9}, Lorg/apache/http/StatusLine;->getStatusCode()I

    move-result v9

    const/16 v10, 0xc8

    if-eq v9, v10, :cond_4a

    .line 72
    new-instance v9, Ljava/lang/RuntimeException;

    const-string v10, "\u8bf7\u6c42\u5931\u8d25"

    invoke-direct {v9, v10}, Ljava/lang/RuntimeException;-><init>(Ljava/lang/String;)V

    throw v9
    :try_end_3f
    .catch Ljava/io/UnsupportedEncodingException; {:try_start_1 .. :try_end_3f} :catch_3f
    .catch Lorg/apache/http/client/ClientProtocolException; {:try_start_1 .. :try_end_3f} :catch_57
    .catch Ljava/io/IOException; {:try_start_1 .. :try_end_3f} :catch_62

    .line 77
    .end local v0    # "client":Lorg/apache/http/client/HttpClient;
    .end local v2    # "httpPost":Lorg/apache/http/client/methods/HttpPost;
    .end local v4    # "params":Ljava/util/List;, "Ljava/util/List<Lorg/apache/http/NameValuePair;>;"
    .end local v6    # "response":Lorg/apache/http/HttpResponse;
    .end local v7    # "urlEncoded":Lorg/apache/http/client/entity/UrlEncodedFormEntity;
    :catch_3f
    move-exception v1

    .line 78
    .local v1, "e":Ljava/io/UnsupportedEncodingException;
    sget-object v9, Lcom/zuiapps/suite/utils/http/CustomHttpClient;->TAG:Ljava/lang/String;

    invoke-virtual {v1}, Ljava/io/UnsupportedEncodingException;->getMessage()Ljava/lang/String;

    move-result-object v10

    invoke-static {v9, v10}, Landroid/util/Log;->w(Ljava/lang/String;Ljava/lang/String;)I

    .line 82
    .end local v1    # "e":Ljava/io/UnsupportedEncodingException;
    :cond_49
    :goto_49
    return-object v8

    .line 74
    .restart local v0    # "client":Lorg/apache/http/client/HttpClient;
    .restart local v2    # "httpPost":Lorg/apache/http/client/methods/HttpPost;
    .restart local v4    # "params":Ljava/util/List;, "Ljava/util/List<Lorg/apache/http/NameValuePair;>;"
    .restart local v6    # "response":Lorg/apache/http/HttpResponse;
    .restart local v7    # "urlEncoded":Lorg/apache/http/client/entity/UrlEncodedFormEntity;
    :cond_4a
    :try_start_4a
    invoke-interface {v6}, Lorg/apache/http/HttpResponse;->getEntity()Lorg/apache/http/HttpEntity;

    move-result-object v5

    .line 75
    .local v5, "resEntity":Lorg/apache/http/HttpEntity;
    if-eqz v5, :cond_49

    const-string v9, "UTF-8"

    invoke-static {v5, v9}, Lorg/apache/http/util/EntityUtils;->toString(Lorg/apache/http/HttpEntity;Ljava/lang/String;)Ljava/lang/String;
    :try_end_55
    .catch Ljava/io/UnsupportedEncodingException; {:try_start_4a .. :try_end_55} :catch_3f
    .catch Lorg/apache/http/client/ClientProtocolException; {:try_start_4a .. :try_end_55} :catch_57
    .catch Ljava/io/IOException; {:try_start_4a .. :try_end_55} :catch_62

    move-result-object v8

    goto :goto_49

    .line 80
    .end local v0    # "client":Lorg/apache/http/client/HttpClient;
    .end local v2    # "httpPost":Lorg/apache/http/client/methods/HttpPost;
    .end local v4    # "params":Ljava/util/List;, "Ljava/util/List<Lorg/apache/http/NameValuePair;>;"
    .end local v5    # "resEntity":Lorg/apache/http/HttpEntity;
    .end local v6    # "response":Lorg/apache/http/HttpResponse;
    .end local v7    # "urlEncoded":Lorg/apache/http/client/entity/UrlEncodedFormEntity;
    :catch_57
    move-exception v1

    .line 81
    .local v1, "e":Lorg/apache/http/client/ClientProtocolException;
    sget-object v9, Lcom/zuiapps/suite/utils/http/CustomHttpClient;->TAG:Ljava/lang/String;

    invoke-virtual {v1}, Lorg/apache/http/client/ClientProtocolException;->getMessage()Ljava/lang/String;

    move-result-object v10

    invoke-static {v9, v10}, Landroid/util/Log;->w(Ljava/lang/String;Ljava/lang/String;)I

    goto :goto_49

    .line 83
    .end local v1    # "e":Lorg/apache/http/client/ClientProtocolException;
    :catch_62
    move-exception v1

    .line 84
    .local v1, "e":Ljava/io/IOException;
    new-instance v8, Ljava/lang/RuntimeException;

    invoke-virtual {p0}, Landroid/content/Context;->getResources()Landroid/content/res/Resources;

    move-result-object v9

    sget v10, Lcom/zuiapps/suite/utils/R$string;->httpError:I

    invoke-virtual {v9, v10}, Landroid/content/res/Resources;->getString(I)Ljava/lang/String;

    move-result-object v9

    invoke-direct {v8, v9, v1}, Ljava/lang/RuntimeException;-><init>(Ljava/lang/String;Ljava/lang/Throwable;)V

    throw v8
.end method

.method public static varargs getFromWebByHttpClient(Landroid/content/Context;Ljava/lang/String;[Lorg/apache/http/NameValuePair;)Ljava/lang/String;
    .registers 13
    .param p0, "context"    # Landroid/content/Context;
    .param p1, "url"    # Ljava/lang/String;
    .param p2, "nameValuePairs"    # [Lorg/apache/http/NameValuePair;

    .prologue
    .line 95
    :try_start_0
    new-instance v5, Ljava/lang/StringBuilder;

    invoke-direct {v5}, Ljava/lang/StringBuilder;-><init>()V

    .line 96
    .local v5, "sb":Ljava/lang/StringBuilder;
    invoke-virtual {v5, p1}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    .line 97
    if-eqz p2, :cond_3e

    array-length v6, p2

    if-lez v6, :cond_3e

    .line 98
    const-string v6, "?"

    invoke-virtual {v5, v6}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    .line 99
    const/4 v4, 0x0

    .local v4, "i":I
    :goto_13
    array-length v6, p2

    if-ge v4, v6, :cond_3e

    .line 100
    if-lez v4, :cond_1d

    .line 101
    const-string v6, "&"

    invoke-virtual {v5, v6}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    .line 103
    :cond_1d
    const-string v6, "%s=%s"

    const/4 v7, 0x2

    new-array v7, v7, [Ljava/lang/Object;

    const/4 v8, 0x0

    aget-object v9, p2, v4

    .line 104
    invoke-interface {v9}, Lorg/apache/http/NameValuePair;->getName()Ljava/lang/String;

    move-result-object v9

    aput-object v9, v7, v8

    const/4 v8, 0x1

    aget-object v9, p2, v4

    .line 105
    invoke-interface {v9}, Lorg/apache/http/NameValuePair;->getValue()Ljava/lang/String;

    move-result-object v9

    aput-object v9, v7, v8

    .line 103
    invoke-static {v6, v7}, Ljava/lang/String;->format(Ljava/lang/String;[Ljava/lang/Object;)Ljava/lang/String;

    move-result-object v6

    invoke-virtual {v5, v6}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    .line 99
    add-int/lit8 v4, v4, 0x1

    goto :goto_13

    .line 109
    .end local v4    # "i":I
    :cond_3e
    new-instance v1, Lorg/apache/http/client/methods/HttpGet;

    invoke-virtual {v5}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v6

    invoke-direct {v1, v6}, Lorg/apache/http/client/methods/HttpGet;-><init>(Ljava/lang/String;)V

    .line 111
    .local v1, "httpRequest":Lorg/apache/http/client/methods/HttpGet;
    invoke-static {p0}, Lcom/zuiapps/suite/utils/http/CustomHttpClient;->getHttpClient(Landroid/content/Context;)Lorg/apache/http/client/HttpClient;

    move-result-object v3

    .line 113
    .local v3, "httpclient":Lorg/apache/http/client/HttpClient;
    invoke-interface {v3, v1}, Lorg/apache/http/client/HttpClient;->execute(Lorg/apache/http/client/methods/HttpUriRequest;)Lorg/apache/http/HttpResponse;

    move-result-object v2

    .line 115
    .local v2, "httpResponse":Lorg/apache/http/HttpResponse;
    invoke-interface {v2}, Lorg/apache/http/HttpResponse;->getStatusLine()Lorg/apache/http/StatusLine;

    move-result-object v6

    invoke-interface {v6}, Lorg/apache/http/StatusLine;->getStatusCode()I

    move-result v6

    const/16 v7, 0xc8

    if-eq v6, v7, :cond_7c

    .line 116
    new-instance v6, Ljava/lang/RuntimeException;

    invoke-virtual {p0}, Landroid/content/Context;->getResources()Landroid/content/res/Resources;

    move-result-object v7

    sget v8, Lcom/zuiapps/suite/utils/R$string;->httpError:I

    invoke-virtual {v7, v8}, Landroid/content/res/Resources;->getString(I)Ljava/lang/String;

    move-result-object v7

    invoke-direct {v6, v7}, Ljava/lang/RuntimeException;-><init>(Ljava/lang/String;)V

    throw v6
    :try_end_6b
    .catch Lorg/apache/http/ParseException; {:try_start_0 .. :try_end_6b} :catch_6b
    .catch Ljava/io/IOException; {:try_start_0 .. :try_end_6b} :catch_85

    .line 120
    .end local v1    # "httpRequest":Lorg/apache/http/client/methods/HttpGet;
    .end local v2    # "httpResponse":Lorg/apache/http/HttpResponse;
    .end local v3    # "httpclient":Lorg/apache/http/client/HttpClient;
    .end local v5    # "sb":Ljava/lang/StringBuilder;
    :catch_6b
    move-exception v0

    .line 121
    .local v0, "e":Lorg/apache/http/ParseException;
    new-instance v6, Ljava/lang/RuntimeException;

    invoke-virtual {p0}, Landroid/content/Context;->getResources()Landroid/content/res/Resources;

    move-result-object v7

    sget v8, Lcom/zuiapps/suite/utils/R$string;->httpError:I

    invoke-virtual {v7, v8}, Landroid/content/res/Resources;->getString(I)Ljava/lang/String;

    move-result-object v7

    invoke-direct {v6, v7, v0}, Ljava/lang/RuntimeException;-><init>(Ljava/lang/String;Ljava/lang/Throwable;)V

    throw v6

    .line 119
    .end local v0    # "e":Lorg/apache/http/ParseException;
    .restart local v1    # "httpRequest":Lorg/apache/http/client/methods/HttpGet;
    .restart local v2    # "httpResponse":Lorg/apache/http/HttpResponse;
    .restart local v3    # "httpclient":Lorg/apache/http/client/HttpClient;
    .restart local v5    # "sb":Ljava/lang/StringBuilder;
    :cond_7c
    :try_start_7c
    invoke-interface {v2}, Lorg/apache/http/HttpResponse;->getEntity()Lorg/apache/http/HttpEntity;

    move-result-object v6

    invoke-static {v6}, Lorg/apache/http/util/EntityUtils;->toString(Lorg/apache/http/HttpEntity;)Ljava/lang/String;
    :try_end_83
    .catch Lorg/apache/http/ParseException; {:try_start_7c .. :try_end_83} :catch_6b
    .catch Ljava/io/IOException; {:try_start_7c .. :try_end_83} :catch_85

    move-result-object v6

    return-object v6

    .line 123
    .end local v1    # "httpRequest":Lorg/apache/http/client/methods/HttpGet;
    .end local v2    # "httpResponse":Lorg/apache/http/HttpResponse;
    .end local v3    # "httpclient":Lorg/apache/http/client/HttpClient;
    .end local v5    # "sb":Ljava/lang/StringBuilder;
    :catch_85
    move-exception v0

    .line 124
    .local v0, "e":Ljava/io/IOException;
    invoke-virtual {v0}, Ljava/io/IOException;->printStackTrace()V

    .line 125
    new-instance v6, Ljava/lang/RuntimeException;

    invoke-virtual {p0}, Landroid/content/Context;->getResources()Landroid/content/res/Resources;

    move-result-object v7

    sget v8, Lcom/zuiapps/suite/utils/R$string;->httpError:I

    invoke-virtual {v7, v8}, Landroid/content/res/Resources;->getString(I)Ljava/lang/String;

    move-result-object v7

    invoke-direct {v6, v7, v0}, Ljava/lang/RuntimeException;-><init>(Ljava/lang/String;Ljava/lang/Throwable;)V

    throw v6
.end method

.method private static declared-synchronized getHttpClient(Landroid/content/Context;)Lorg/apache/http/client/HttpClient;
    .registers 10
    .param p0, "context"    # Landroid/content/Context;

    .prologue
    .line 137
    const-class v5, Lcom/zuiapps/suite/utils/http/CustomHttpClient;

    monitor-enter v5

    :try_start_3
    sget-object v4, Lcom/zuiapps/suite/utils/http/CustomHttpClient;->customerHttpClient:Lorg/apache/http/client/HttpClient;

    if-nez v4, :cond_67

    .line 138
    new-instance v2, Lorg/apache/http/params/BasicHttpParams;

    invoke-direct {v2}, Lorg/apache/http/params/BasicHttpParams;-><init>()V

    .line 140
    .local v2, "params":Lorg/apache/http/params/HttpParams;
    sget-object v4, Lorg/apache/http/HttpVersion;->HTTP_1_1:Lorg/apache/http/HttpVersion;

    invoke-static {v2, v4}, Lorg/apache/http/params/HttpProtocolParams;->setVersion(Lorg/apache/http/params/HttpParams;Lorg/apache/http/ProtocolVersion;)V

    .line 141
    const-string v4, "UTF-8"

    invoke-static {v2, v4}, Lorg/apache/http/params/HttpProtocolParams;->setContentCharset(Lorg/apache/http/params/HttpParams;Ljava/lang/String;)V

    .line 142
    const/4 v4, 0x1

    invoke-static {v2, v4}, Lorg/apache/http/params/HttpProtocolParams;->setUseExpectContinue(Lorg/apache/http/params/HttpParams;Z)V

    .line 143
    const-string v4, "Mozilla/5.0(Linux;U;Android 2.2.1;en-us;Nexus One Build.FRG83) AppleWebKit/553.1(KHTML,like Gecko) Version/4.0 Mobile Safari/533.1"

    .line 144
    invoke-static {v2, v4}, Lorg/apache/http/params/HttpProtocolParams;->setUserAgent(Lorg/apache/http/params/HttpParams;Ljava/lang/String;)V

    .line 150
    const-wide/16 v6, 0x3e8

    invoke-static {v2, v6, v7}, Lorg/apache/http/conn/params/ConnManagerParams;->setTimeout(Lorg/apache/http/params/HttpParams;J)V

    .line 152
    const/16 v0, 0xbb8

    .line 153
    .local v0, "ConnectionTimeOut":I
    invoke-static {p0}, Lcom/zuiapps/suite/utils/http/HttpUtils;->isWifiDataEnable(Landroid/content/Context;)Z

    move-result v4

    if-nez v4, :cond_2e

    .line 154
    const/16 v0, 0x2710

    .line 157
    :cond_2e
    invoke-static {v2, v0}, Lorg/apache/http/params/HttpConnectionParams;->setConnectionTimeout(Lorg/apache/http/params/HttpParams;I)V

    .line 159
    const/16 v4, 0xfa0

    invoke-static {v2, v4}, Lorg/apache/http/params/HttpConnectionParams;->setSoTimeout(Lorg/apache/http/params/HttpParams;I)V

    .line 161
    new-instance v3, Lorg/apache/http/conn/scheme/SchemeRegistry;

    invoke-direct {v3}, Lorg/apache/http/conn/scheme/SchemeRegistry;-><init>()V

    .line 162
    .local v3, "schReg":Lorg/apache/http/conn/scheme/SchemeRegistry;
    new-instance v4, Lorg/apache/http/conn/scheme/Scheme;

    const-string v6, "http"

    .line 163
    invoke-static {}, Lorg/apache/http/conn/scheme/PlainSocketFactory;->getSocketFactory()Lorg/apache/http/conn/scheme/PlainSocketFactory;

    move-result-object v7

    const/16 v8, 0x50

    invoke-direct {v4, v6, v7, v8}, Lorg/apache/http/conn/scheme/Scheme;-><init>(Ljava/lang/String;Lorg/apache/http/conn/scheme/SocketFactory;I)V

    .line 162
    invoke-virtual {v3, v4}, Lorg/apache/http/conn/scheme/SchemeRegistry;->register(Lorg/apache/http/conn/scheme/Scheme;)Lorg/apache/http/conn/scheme/Scheme;

    .line 164
    new-instance v4, Lorg/apache/http/conn/scheme/Scheme;

    const-string v6, "https"

    .line 165
    invoke-static {}, Lorg/apache/http/conn/ssl/SSLSocketFactory;->getSocketFactory()Lorg/apache/http/conn/ssl/SSLSocketFactory;

    move-result-object v7

    const/16 v8, 0x1bb

    invoke-direct {v4, v6, v7, v8}, Lorg/apache/http/conn/scheme/Scheme;-><init>(Ljava/lang/String;Lorg/apache/http/conn/scheme/SocketFactory;I)V

    .line 164
    invoke-virtual {v3, v4}, Lorg/apache/http/conn/scheme/SchemeRegistry;->register(Lorg/apache/http/conn/scheme/Scheme;)Lorg/apache/http/conn/scheme/Scheme;

    .line 168
    new-instance v1, Lorg/apache/http/impl/conn/tsccm/ThreadSafeClientConnManager;

    invoke-direct {v1, v2, v3}, Lorg/apache/http/impl/conn/tsccm/ThreadSafeClientConnManager;-><init>(Lorg/apache/http/params/HttpParams;Lorg/apache/http/conn/scheme/SchemeRegistry;)V

    .line 170
    .local v1, "conMgr":Lorg/apache/http/conn/ClientConnectionManager;
    new-instance v4, Lorg/apache/http/impl/client/DefaultHttpClient;

    invoke-direct {v4, v1, v2}, Lorg/apache/http/impl/client/DefaultHttpClient;-><init>(Lorg/apache/http/conn/ClientConnectionManager;Lorg/apache/http/params/HttpParams;)V

    sput-object v4, Lcom/zuiapps/suite/utils/http/CustomHttpClient;->customerHttpClient:Lorg/apache/http/client/HttpClient;

    .line 172
    .end local v0    # "ConnectionTimeOut":I
    .end local v1    # "conMgr":Lorg/apache/http/conn/ClientConnectionManager;
    .end local v2    # "params":Lorg/apache/http/params/HttpParams;
    .end local v3    # "schReg":Lorg/apache/http/conn/scheme/SchemeRegistry;
    :cond_67
    sget-object v4, Lcom/zuiapps/suite/utils/http/CustomHttpClient;->customerHttpClient:Lorg/apache/http/client/HttpClient;
    :try_end_69
    .catchall {:try_start_3 .. :try_end_69} :catchall_6b

    monitor-exit v5

    return-object v4

    .line 137
    :catchall_6b
    move-exception v4

    monitor-exit v5

    throw v4
.end method
